package org.dromara.solonplugins.nutzdao.test1;

import java.util.Date;

import org.dromara.solonplugins.nutzdao.annotation.Db;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.noear.solon.test.SolonJUnit5Extension;
import org.noear.solon.test.SolonTest;
import org.nutz.dao.Chain;
import org.nutz.dao.Cnd;
import org.nutz.dao.impl.NutDao;
import org.nutz.json.JsonFormat;

@ExtendWith(SolonJUnit5Extension.class)
@SolonTest(TestApp1.class)
public class DemoAppTest1 {
	
	@Db
	private NutDao dao;
	
	@Test
	public void test() {
		// 根据主键获取
		dao.insert("import_file", Chain.make("id","2").add("importDate", new Date()));
		org.nutz.dao.entity.Record re = dao.fetch("import_file", Cnd.where("id","=",2));
		// 转换成 Json 字符串
		String json = re.toJson(JsonFormat.nice());
		System.out.println(json);
	}

}
